"""
hello => olleh

"""
def reverse(s):
    l = list(s)
    for i in range(len(l)//2):
        l[i], l[len(l) -1 -i] = l[len(l) -1 -i], l[i]  # 交换
    return ''.join(l)

s = 'hello'
r = reverse(s)
print(r)

# O(n)